package com.hspedu.set_;

import java.util.HashSet;
import java.util.LinkedHashSet;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/2/8
 * @time 19:14
 */
public class TestLinkedHashSet {
    public static void main(String[] args) {
        int[] arr = null;
        int[] arr2 = arr;
        arr = new int[10];


        HashSet hashSet = new HashSet();
        hashSet.add(new A(1));
        hashSet.add(new A(2));

        LinkedHashSet linkedHashSet = new LinkedHashSet();
        linkedHashSet.add(1);
        linkedHashSet.add(new A(2));
        linkedHashSet.add(3);
        linkedHashSet.add(new A(4));

        System.out.println("linkedHashSet = " + linkedHashSet);
    }
}

class A{
    private int m ;


    @Override
    public String toString() {
        return "A{" +
                "m=" + m +
                '}';
    }

    @Override
    public int hashCode() {
        return 100;
    }

    public A(int m) {
        this.m = m;
    }
}
